const Router = require("koa-router")
const User = require('../mongooes/schemas/user')

const router = new Router()

router.post('/login', ctx => {
    // ctx.body = "login"
    console.log("注册成功");
    let user = new User({
        username: 'weipeng',
        passward: 'wp4545355'
    })
    user.save(function(err){
        if (err) {
          console.log(err);
        } else {
          console.log("你好")
       }
     })
    ctx.body = "注册成功"
})
 
router.post('/loginout',async ctx => {
    console.log("nihao ");
    let result = await User.find({}).exec()
    if(result) {
        ctx.body =  result
    } else {
        ctx.body = "meiyou"
    }
})

module.exports = router